package com.xywh.micro_warehousing.mvp.ui.adapter;

import android.content.Context;
import android.content.res.Resources;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.SharedPreferencesHelper;
import com.xywh.micro_warehousing.R;
import com.xywh.micro_warehousing.mvp.ui.entity.Tab1;

import java.util.List;

import me.jessyan.armscomponent.commonres.view.RecycleViewDivider;

/**
 * @ProjectName:
 * @ackage: com.xywh.micro_warehousing.mvp.ui.adapter
 * @ClassName: Tab1Adapter
 * @Description: 一级：智能微仓储柜子所在的位置、地址
 * @Author: 小星
 * @CreateDate: 2020/6/22 0022 14:10
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/6/22 0022 14:10
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class Tab1Adapter extends BaseQuickAdapter<Tab1.DataBean, BaseViewHolder> {

    private Context mContext;
    private SharedPreferencesHelper mSharedPreferencesHelper;

    public Tab1Adapter(Context context, @Nullable List<Tab1.DataBean> data, SharedPreferencesHelper sharedPreferencesHelper) {
        super(R.layout.item_tab1, data);
        this.mContext = context;
        this.mSharedPreferencesHelper = sharedPreferencesHelper;
    }

    @Override
    protected void convert(BaseViewHolder helper, Tab1.DataBean item) {
        //GlideUtil.loadImage(mContext,item.getImg(),helper.getView(R.id.img_head));
        try {
            helper.setText(R.id.tv_ming_cheng, item.getStoreName());
            helper.setText(R.id.tv_di_zhi, "仓库地址：" + item.getStoreAdd());

            if (item.getCounters() != null && item.getCounters().size() > 0) {

                RecyclerView recyclerView = helper.getView(R.id.recyclerView);
                recyclerView.addItemDecoration(new RecycleViewDivider(mContext, LinearLayoutManager.HORIZONTAL, 0, mContext.getResources().getColor(R.color.public_client_line_color)));
                CountersAdapter mAdapter = new CountersAdapter(mContext, item.getCounters());
                LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
                linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                recyclerView.setLayoutManager(linearLayoutManager);
                recyclerView.setAdapter(mAdapter);
            }
        } catch (Resources.NotFoundException e) {
            e.printStackTrace();
        }

    }


}
